/// <reference path="../_all.ts" />

module Application.Resources {
    export interface IConfigClass extends ng.resource.IResourceClass {
        saveCollection(params: any, data: any, success?: Function, error?: Function): IConfig[];
    }

    export interface IServerConfigClass extends ng.resource.IResourceClass {
    }

    export interface IConfig extends ng.resource.IResource {
        config_id: number;
        server_id: number;
        name: string;
        desc: string;
        value: string;
        is_visible: boolean;
        is_writable: boolean;
        is_active: boolean;
        created_at: Date;
        updated_at: Date;
        $saveCollection(): IConfig[];
    }

    export class ConfigUtility {
        static fixBooleans(item: IConfig) {
            item.is_visible = Application.Utility.Booleans.parse(item.is_visible, true);
            item.is_writable = Application.Utility.Booleans.parse(item.is_writable, true);
            item.is_active = Application.Utility.Booleans.parse(item.is_active, true);
        }
    }
}